package com.tarena.lbs.business.servcie.impl;

import com.tarena.lbs.business.dao.mapper.BusinessCategoryMapper;
import com.tarena.lbs.business.pojo.vo.BusinessCategoryVO;
import com.tarena.lbs.business.servcie.BusinessCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class BusinessCategoryServiceImpl implements BusinessCategoryService {
    @Autowired
    BusinessCategoryMapper businessCategoryMapper;
    @Override
    public List<BusinessCategoryVO> listAllCategories() {
        List<BusinessCategoryVO> categories = businessCategoryMapper.selectAll();
        return convertToVOList(categories);
    }

    private List<BusinessCategoryVO> convertToVOList(List<BusinessCategoryVO> categories) {
        return categories.stream()
                .map(this::convertToVO)
                .toList();
    }

    private BusinessCategoryVO convertToVO(BusinessCategoryVO category) {
        BusinessCategoryVO vo = new BusinessCategoryVO();
        vo.setId(category.getId());
        vo.setLabel(category.getLabel());
        vo.setRemark(category.getRemark());
        vo.setSort(category.getSort());
        vo.setStatus(category.getStatus());
        vo.setCreateTime(category.getCreateTime());
        vo.setUpdateTime(category.getUpdateTime());
        return vo;
    }
}

